import 'package:flutter/widgets.dart';
import 'package:full_display/page/medium/cell_widgets/item_media.dart';
import 'package:full_display/page/medium/local_provider.dart';
import 'package:full_display/unit/screen/screen_utility.dart';
import 'package:provider/provider.dart';

class LocalMediaWidget extends StatelessWidget {

  String type;

  LocalMediaWidget({Key? key,this.type = 'local'}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (_) => MediaProvider(),
        )
      ],
      child: const LocalMediaPage(),
    );
  }
}

class LocalMediaPage extends StatefulWidget {
  const LocalMediaPage({Key? key}) : super(key: key);

  @override
  State<LocalMediaPage> createState() => _LocalMediaPageState();
}

class _LocalMediaPageState extends State<LocalMediaPage> {
  var _mediaProvider = MediaProvider();

  @override
  Widget build(BuildContext context) {
    _mediaProvider = context.watch<MediaProvider>();

    return Container(
        margin: EdgeInsets.only(top: 24.0.H),
        child: GridView.builder(
          padding: EdgeInsets.only(
            left: 20.0.W,
            right: 20.0.W,
          ),
          itemCount: /*_mediaProvider.mediaList.length*/ 100,
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              childAspectRatio: 104 / 130,
              crossAxisCount: 3,
              crossAxisSpacing: 12.0.W,
              mainAxisSpacing: 12.0.H),
          itemBuilder: (context, index) {
            return ItemMedia(bottomTitle: "本地",);
          },
        ));
  }
}
